﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using CoolCode.WebServices;

namespace CoolCode.Web.UI.WebServices
{
    /// <summary>
    /// Summary description for $codebehindclassname$
    /// </summary>
    //[WebService(Namespace = "http://tempuri.org/")]
    //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class FileHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string key = RequestUtility.GetQueryString("key");
            if (string.IsNullOrEmpty(key))
            { 
                this.Warning("无效操作!");
            }

            key = key.Trim();
            string savePath = Path.Combine(Utility.GetMapPath("~/Output/"), key);

            if (!File.Exists(savePath))
            {
                this.Warning("找不到文件:"+key );
            } 

            this.WriteFile(FileType.Excel, savePath);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
